<?php 
//如果用户有提交的时候（点“计算”的时候）
if($_POST){
	$num1 = $_POST['num1'];
	$num2 = $_POST['num2'];
	$yunsuan = $_POST['yunsuan'];
	switch ($yunsuan) {
		case '+':
			$re = $num1 + $num2;
			break;
		
		default:
			
			break;
	}
}


 ?>
 <!doctype html>
 <html lang="en">
 <head>
 	<meta charset="UTF-8" />
 	<title>Document</title>
 </head>
 <body>
 	<h2>结果：<span style="color: red;"><?php echo $re ?></span></h2>
 	<form action="" method="post">
 		数字1：
 		<input type="text" name="num1" id="" required=""/>
 		<br />
 		运算符：
 		<select name="yunsuan">
 			<option value="+">+</option>
 			<option value="-">-</option>
 			<option value="*">*</option>
 			<option value="/">/</option>
 		</select>
 		<br />
 		数字2：
 		<input type="text" name="num2" id=""  required=""/>
 		<br />
 		<input type="submit" value="计算"/>
 	</form>
 </body>
 </html>